package com.epalmpay.service.bonus.impl;

import com.epalmpay.dto.bonus.*;
import com.epalmpay.entity.Page;
import com.epalmpay.mapper.BonusVerifyLogMapper;
import com.epalmpay.service.bonus.IBonusVerifyLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/9/20.
 */
@Service("bonusVerifyLogService")
public class BonusVerifyLogServiceImpl implements IBonusVerifyLogService{

    @Resource
    private BonusVerifyLogMapper bonusVerifyLogMapper;

    @Override
    public BonusVerifyLogListOutDTO selectBonusVerifyLogList(BonusVerifyLogInDTO bonusVerifyLogInDTO, Page page) throws Exception {

        BonusVerifyLogListOutDTO bonusVerifyLogListOutDTO = new BonusVerifyLogListOutDTO();

        Map<String,Object> param=new HashMap<String,Object>();
        param.put("groupId",bonusVerifyLogInDTO.getGroupId());
        param.put("industryId",bonusVerifyLogInDTO.getIndustryId());
        param.put("shopName",bonusVerifyLogInDTO.getShopName());
        param.put("adjustStatus",bonusVerifyLogInDTO.getAdjustStatus());
        param.put("verifyType",bonusVerifyLogInDTO.getVerifyType());
        param.put("joinStart",bonusVerifyLogInDTO.getJoinStart());
        param.put("joinEnd",bonusVerifyLogInDTO.getJoinEnd());



        int sumCount = bonusVerifyLogMapper.selectBonusVerifyLogCount(param);
        page.setTotalResult(sumCount);
        if(sumCount<=0)
            return bonusVerifyLogListOutDTO;

        param.put("limit", page.getShowCount());
        param.put("start", page.getShowCount()*(page.getCurrentPage()-1));

        List<BonusVerifyLogOutDTO> bonusVerifyLogOutDTOList = bonusVerifyLogMapper.selectBonusVerifyLogList(param);
        bonusVerifyLogListOutDTO.setBonusVerifyLogOutDTOList(bonusVerifyLogOutDTOList);
        return bonusVerifyLogListOutDTO;
    }

    @Override
    public BonusVerifyLogOutDTO queryBonusVerifyLogDetail(BonusVerifyLogInDTO bonusVerifyLogInDTO) throws Exception {
        return bonusVerifyLogMapper.queryBonusVerifyLogDetail(bonusVerifyLogInDTO);
    }

}
